<template>
  <div :class="{barBack:!config.mainBool}" class="top-bar" v-if="true">
    <img
      :src="config.mainBool?img2:img1"
      @click="goback"
    >
    <p
      class="top-bar-title"
      :class="[config.mainBool?'mainBar':'']"
    >
      {{config.title}}
    </p>
    <div>
      <slot name="topBar_slot"></slot>
    </div>
  </div>
</template>
<script>
export default {
  props:{
    gobackBool:{
      type:Boolean,
      default:false
    },
    config:{
      type:Object,
      default:() => {
        return{
          title:'新建地址',
          seek:'',
          mainBool:false
        }
      }
    }
  },
  data(){
    return {
      img1:require('../../assets/go1.png'),
      img2:require('../../assets/go2.png'),
      port:null
    }
  },
  created(){
    this.checkport()
  },
  methods:{
    goback(){
      if(this.gobackBool) this.$emit('goback');
      else this.$router.go(-1);
    },
    // 判断登录端口控制tabbar是否显示
    checkport(){
      var ua = window.navigator.userAgent.toLowerCase();
      //判断是不是微信
      if (ua.match(/MicroMessenger/i) == 'micromessenger') {
        this.port = 'weixin';
        //判断是不是支付宝
      }else if (ua.match(/AlipayClient/i) == 'alipayclient') {
        this.port = 'zlb';
        //判断是不是钉钉
      }else if (ua.match(/DingTalk/i) == 'dingtalk') {
        this.port = 'ding';
        //判断是不是浙里办
      }else if (ua.match(/hanweb/i) == 'hanweb' ){
        this.port = 'zlb';
      }else {
        this.port = 'app';
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.barBack{
  background: #fff;
}
.mainBar{
  color: #fff !important;
}
.top-bar{
  width: 3.75rem;
  height: 0.44rem;
  padding: 0.1rem 0.12rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  img{
    height: 0.24rem;
    width: 0.24rem;
    display: block;
  }
  .top-bar-title{
    font-size: 0.17rem;
    font-family: PingFang SC-中黑体, PingFang SC;
    font-weight: bold;
    color: #363A44;
  }
  .top-bar-seek{
    min-width:0.24rem;
    font-size: 0.14rem;
    font-family: PingFang SC-常规体, PingFang SC;
    font-weight: normal;
    color: #363A44;
    line-height: 0.24rem;
  }
}
</style>
